package com.example.aidrawavatar.adapter;

import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import androidx.annotation.NonNull;
import androidx.recyclerview.widget.RecyclerView;
import com.bumptech.glide.Glide;
import com.bumptech.glide.load.engine.DiskCacheStrategy;
import com.example.aidrawavatar.R;
import com.example.aidrawavatar.databinding.ItemActivityRecycleViewBinding;
import com.example.aidrawavatar.utils.RetrofitUtils;

public class MainActivityAdapter extends RecyclerView.Adapter<MainActivityAdapter.MyViewHolder> {
    @NonNull
    @Override
    public MyViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
        return new MyViewHolder(LayoutInflater.from(parent.getContext()).inflate(R.layout.item_activity_recycle_view,parent,false));
    }

    @Override
    public void onBindViewHolder(@NonNull MyViewHolder holder, int position) {
        ItemActivityRecycleViewBinding binding = ItemActivityRecycleViewBinding.bind(holder.itemView);
        String imageUrl = RetrofitUtils.getInstance().getImageStation() + position + ".jpg";
        Glide.with(binding.activityMainImage)
                .load(imageUrl)
                .diskCacheStrategy(DiskCacheStrategy.NONE)
                .skipMemoryCache(true)
                .into(binding.activityMainImage);
        binding = null;
    }

    @Override
    public int getItemCount() {
        return 9;
    }

    public static class MyViewHolder extends RecyclerView.ViewHolder {
        public MyViewHolder(@NonNull View itemView) {
            super(itemView);
        }
    }
}
